import requests
import pandas as pd


def geocode(key, address):
    # 获取高德地图API的地理编码信息
    url = "https://restapi.amap.com/v3/geocode/geo?parameters"
    params = {
        "key": key,
        "address": address,
        "city": '广州'
    }
    response = requests.get(url=url, params=params)
    return response.json()['geocodes'][0]['location']


def planning(departure, destination):
    # 获得步行德路径规划API
    url_bus = "https://restapi.amap.com/v3/direction/walking?parameters"
    params_bus = {
        "key": '2d015ae1da99945790f1601af060c108',
        "origin": departure,
        "destination": destination,
        "city": '广州',
    }
    r = requests.get(url_bus, params_bus)
    return r.json()['route']['paths'][0]['steps']


def getinfo(results):
    a = results
    b = []
    for i in range(0, len(a)):
        a[i].pop('duration')
        a[i].pop('polyline')
        a[i].pop('assistant_action')
        a[i].pop('walk_type')
        a[i].pop('orientation')
        a[i].pop('road')
        a[i].pop('distance')
        a[i].pop('action')
        b.append(a[i].pop('instruction'))
    return '--->'.join(b)
